<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="author" content="林镭特">
    <title></title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
    .bgc{
        width: 100%;
        height: 2000px;
        background-color: darkgray;
    }
    nav{
        display: flex;
            flex-direction: column;
            position: fixed;
            right: 0;
            top: 50%;
    }
    i{
        display: inline-block;
            width: 15px;
            height: 36px;
            background-size: 90%;
            background: url('img/scroll.png') no-repeat;
    }
    .top i{
        background-position: 2px 0;
    }
    .down i{
        background-position: 2px -80px;
    }
    .item{
        position: relative;
    }
    span{
        color: white;
        position: absolute;
        left: -75px;
        width: 80px;
        top: 0;
        border-radius: 15px 0 0 15px;
        padding-left: 10px;
        transition: all 0.3s;
        line-height: 40px;
        opacity: 0;
    }
    .top span{
        background-color: #d03f42;
    }
    .down span{
        background-color: #2F3634;
    }
    </style>
</head>
<body>
    <div class="bgc"></div>

    <nav>
        <div class="item top">
            <i></i>
            <span>返回顶部</span>
        </div>
        <div class="item down">
            <i></i>
            <span>返回底部</span>
        </div>
    </nav>
<script src="jQuery.js"></script>
<script>
     $('.item').hover(function () {
        $(this).find('span').css('opacity', 1)
    }, function () {
        $(this).find('span').css('opacity', 0)
    });
   
    $('.top').click(function () {
        $('html,body').animate({'scrollTop': '0px'})
    })
    $('.down').click(function () {
        $('html').animate({'scrollTop': $('body').height()})
    })
</script>
</body>
</html>